using System;
using System.Collections;
using System.Collections.Generic;

namespace Drill
{
    /// <summary>
    /// Interface implemented by classes used to resolve dependency types, 
	/// locate services or obtain object instances from containers, locators, 
	/// factories, contexts or other sources.
    /// </summary>
    /// <remarks>
    /// Implementers can implement one of two public constructor signatures:
	/// public MyDependencyResolver() or public MyDependencyResolver(IDependencyResolverInitContext context).
	/// The constructor signature with the constructor context argument is the recommended constructor signature.
    /// </remarks>
    public interface IDependencyResolver : IDisposable
    {
        /// <summary>
        /// Gets an instance of the type specified by <paramref name="targetType"/>.
        /// </summary>
        /// <param name="targetType">The type of object to be retrieved.</param>
        /// <returns>An instance of the requested type.</returns>
        object GetInstance(Type targetType);

        /// <summary>
        /// Gets a named instance of the type specified by <paramref name="targetType"/>.
        /// </summary>
        /// <param name="targetType">The type of object to be retrieved.</param>
        /// <param name="name">The name of the specific object instance.</param>
        /// <returns>An instance of the requested named type.</returns>
        object GetInstance(Type targetType, string name);

        /// <summary>
        /// Get all instances of the type specified by <paramref name="targetType"/>.
        /// </summary>
        /// <param name="targetType">The type of object to be retrieved.</param>
        /// <returns>
        /// An <see cref="IEnumerable"/> instance representing all 
        /// available instances of the requested type.
        /// </returns>
        IEnumerable GetAllInstances(Type targetType);

        /// <summary>
        /// Gets an instance of the type specified by <typeparamref name="TTargetType"/>.
        /// </summary>
        /// <typeparam name="TTargetType">The type of object to be retrieved.</typeparam>
        /// <returns>An instance of the requested type.</returns>
        TTargetType GetInstance<TTargetType>();

        /// <summary>
        /// Gets a named instance of the type specified by <typeparamref name="TTargetType"/>.
        /// </summary>
        /// <typeparam name="TTargetType">The type of object to be retrieved.</typeparam>
        /// <param name="name">Name the object was registered with.</param>
        /// <returns>An instance of the requested named type.</returns>
        TTargetType GetInstance<TTargetType>(string name);

        /// <summary>
        /// Get all instances of the type specified by <typeparamref name="TTargetType"/>.
        /// </summary>
        /// <typeparam name="TTargetType">The type of object to be retrieved.</typeparam>
        /// <returns>
        /// An <see cref="IEnumerable{TTargetType}"/> instance representing all 
        /// available instances of the requested type.
        /// </returns>
        IEnumerable<TTargetType> GetAllInstances<TTargetType>();
    }
}